<?php
// +----------------------------------------------------------------------
// |商品库存自动任务
// +----------------------------------------------------------------------
// |Data:2016-06-29 上午10:22
// +----------------------------------------------------------------------
// |Author: 吕志雄 <870923001@qq.com>
// +----------------------------------------------------------------------
namespace Cli\Model;
class CronProductModel{

    /**
     * 更新库存(一天一次)
     */
    public function updateStore(){
        while(true){
            $data = S('ps_product_store_list');
            if(empty($data)) break;
            foreach($data as $k=>$v){
                $result = unserialize($v);
                $res = M('project')->where('id='.$result['product_id'])->setInc('store',$result['num']);
                if($res){
                    unset($data[$k]);
                    S('ps_product_store_list',$data);
                }
            }
        }
    }
}
?>